package engine.util.vector;

public class Vector {

	public static final double[] ZERO3 = new double[]{0, 0, 0};
	
	private Vector() {}
	
	public static double length(double[] v) {
		return Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
	}
	
	public static double[] normalize(double[] v) {
		double length = length(v);
		return new double[]{v[0] / length, v[1] / length, v[2] / length};
	}
	
	public static double[] random(int size, double range) {
		double[] ret = new double[size];
		for(int i = 0; i < ret.length; i++) {
			ret[i] = Math.random() * range;
		}
		return ret;
	}
	
	public static double[] mult(double[] v, double s) {
		return new double[]{v[0] * s, v[1] * s, v[2] * s};
	}
	
	public static double mult(double[] v1, double[] v2) {
		return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
	}
	
	public static double[] add(double[] v1, double[] v2) {
		return new double[]{v1[0] + v2[0], v1[1] + v2[1], v1[2] + v2[2]};
	}
	
	public static double[] sub(double[] v1, double[] v2) {
		return new double[]{v1[0] - v2[0], v1[1] - v2[1], v1[2] - v2[2]};
	}
}
